package com.zy.design.demo.structural;

/**
 * 装饰器模式
 * 特点：动态添加功能。
 */
interface Coffee {
    String getDescription();
}

class SimpleCoffee implements Coffee {
    public String getDescription() { return "普通咖啡"; }
}

class MilkDecorator implements Coffee {
    private Coffee coffee;

    public MilkDecorator(Coffee coffee) { this.coffee = coffee; }

    public String getDescription() { return coffee.getDescription() + " 加牛奶"; }
}

class Main3 {
    public static void main(String[] args) {
        Coffee coffee = new SimpleCoffee();
        coffee = new MilkDecorator(coffee);
        System.out.println(coffee.getDescription());
    }
}
